package Mmethod;

import book.*;

import java.util.Scanner;

public class deletebook implements gather {
    @Override
    public void work(booklist book) {
        System.out.println("请输入要删除的书名");
        Scanner sacn=new Scanner(System.in);
        String name= sacn.nextLine();
        for (int i=0;i<book.getBookcontent();i++){
            if (name.equals(book.getarr(i).getName())){
                if (book.getarr(i+1)==null){
                    book.setarr(null,i);
                }else {
                    for (int j=i;book.getarr(j+1)!=null;j++){
                        book.setarr(book.getarr(j+1),j);
                    }
                }
                int a=book.getBookcontent();
                book.setBookcontent(--a);
                System.out.println("删除成功");
                return;
            }
        }
        System.out.println("没有找到要删除的书籍");
    }
}
